﻿using Compass.Wasm.Shared;
using Compass.Wasm.Shared.Purchases;
using System.Collections.Generic;

namespace Compass.Wpf.ApiServices.Purchases;
public interface INavInvValuationService:IBaseService<NavInvValuationDto>
{
    Task<ApiResponse<NavInvValuationDto>> GetSingleByNumberAndMonthAsync(string number,DateTime month);
    Task<ApiResponse<List<NavInvValuationDto>>> GetAllByNumberAndPeriodAsync(string number,DateTime start, DateTime end);
    Task<ApiResponse<List<NavMonthlyValuationDto>>> GetMonthlyValuationsAsync();
}
public class NavInvValuationService:BaseService<NavInvValuationDto>,INavInvValuationService
{
    #region ctor
    private readonly HttpRestClient _client;
    private const string ServiceName = "NavInvValuation";
    public NavInvValuationService(HttpRestClient client) : base(client, ServiceName)
    {
        _client = client;
    }
    #endregion

    #region 扩展查询

    public async Task<ApiResponse<NavInvValuationDto>> GetSingleByNumberAndMonthAsync(string number, DateTime month)
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/Number?number={number}&month={month}"
        };
        return await _client.ExecuteAsync<NavInvValuationDto>(request);
    }

    public async Task<ApiResponse<List<NavInvValuationDto>>> GetAllByNumberAndPeriodAsync(string number,DateTime start, DateTime end)
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/Period?number={number}&start={start}&end={end}"
        };
        return await _client.ExecuteAsync<List<NavInvValuationDto>>(request);
    }

    public async Task<ApiResponse<List<NavMonthlyValuationDto>>> GetMonthlyValuationsAsync()
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/MonthlyValuations"
        };
        return await _client.ExecuteAsync<List<NavMonthlyValuationDto>>(request);
    }

    #endregion
}